<ion-view id="view-confirm" hide-tabs>
  <ion-nav-bar class="bar-royal">
    <ion-nav-title>
      {{'Confirm'|translate}}
    </ion-nav-title>
    <ion-nav-back-button>
    </ion-nav-back-button>
  </ion-nav-bar>

  <ion-content class="add-bottom-for-cta">
    <div class="list">
      <div class="item head" ng-hide="criticalError">
        <div class="sending-label">
          <img src="img/icon-tx-sent-outline.svg">
          <span translate ng-if="!tx.sendMax">Sending</span>
          <span translate ng-if="tx.sendMax">Sending maximum amount</span>
        </div>
        <div class="amount-label">
          <div class="amount">{{tx.amountValueStr || '...'}} <span class="unit">{{tx.amountUnitStr}}</span></div>
          <div class="alternative">{{tx.alternativeAmountStr || '...'}}</div>
        </div>
      </div>

      <div class="info">
        <div class="item item-icon-right" ng-if="wallet" ng-click="chooseFeeLevel(tx, wallet)">
          <span class="label">{{'Wificoin miner fee:' | translate}} {{tx.feeLevelName | translate}}</span>
            <span class="m10l">{{tx.txp[wallet.id].feeStr || '...'}}</span>
            <span class="item-note m10l">
              <span>{{tx.txp[wallet.id].alternativeFeeStr || '...'}}&nbsp;
              <span class="fee-rate" ng-if="tx.txp[wallet.id].feeRatePerStr"> &middot;
                <i class="ion-alert-circled warn" ng-show="tx.txp[wallet.id].feeTooHigh"></i> &nbsp;
                <span class="fee-rate" ng-class="{'warn': tx.txp[wallet.id].feeTooHigh}" translate> {{tx.txp[wallet.id].feeRatePerStr}}  of the sending amount </span>
              </span>
              </span>
            </span>
          <i ng-if="wallet.coin == 'btc'" class="icon bp-arrow-right"></i>
        </div>

        <div class="item single-line" ng-if="tx.paypro">
          <span class="label" translate>Payment Expires:</span>
          <span class="item-note" ng-if="!paymentExpired">{{remainingTimeStr}}</span>
          <span class="item-note" ng-if="paymentExpired" ng-style="{'color': 'red'}" translate>Expired</span>
        </div>

        <div class="item" ng-hide="criticalError">
          <span class="label" translate>To</span>
          <span class="payment-proposal-to" ng-if="!recipientType">
            <img src="img/icon-bitcoin-small.svg">

            <div copy-to-clipboard="tx.origToAddress" ng-if="!tx.paypro" class="ellipsis">
              <contact ng-if="tx.origToAddress && !tx.toName" address="{{tx.origToAddress}}"></contact>
              <span class="m15l size-14" ng-if="tx.toName">{{tx.toName}}</span>
            </div>

            <div ng-if="tx.paypro" ng-click="openPPModal(tx.paypro)" class="m15l size-14 w100p pointer">
              <i ng-show="tx.paypro.verified && tx.paypro.caTrusted" class="ion-locked" style="color:green"></i>
              <i ng-show="!tx.paypro.verified && tx.paypro.caTrusted" class="ion-unlocked" style="color:orange"></i>
              <i ng-show="!tx.paypro.caTrusted" class="ion-unlocked" style="color:red"></i>
              <span class="ellipsis" ng-show="!tx.toName">{{tx.paypro.domain || tx.paypro.toAddress}}</span>
              <span ng-show="tx.toName">{{tx.toName}}</span>
            </div>
            <!-- <contact ng-if="!tx.hasMultiplesOutputs" class="ellipsis" address="{{tx.toAddress}}"></contact>
            <span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span> -->
          </span>
          <div class="wallet" ng-if="recipientType == 'wallet'">
            <i class="icon big-icon-svg">
              <img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !toColor}" ng-style="{'background-color': toColor}" class="bg"/>
            </i>
            <div copy-to-clipboard="tx.origToAddress" class="ellipsis">
              <contact ng-if="tx.origToAddress && !tx.toName" address="{{tx.origToAddress}}"></contact>
              <span ng-if="tx.toName" class="wallet-name">{{tx.toName}}</span>
            </div>
          </div>
          <div ng-if="recipientType == 'contact' && !isChromeApp" class="gravatar-contact toggle" ng-click="toggleAddress()">
            <gravatar class="send-gravatar" name="{{tx.toName}}" height="30" width="30" email="{{toEmail}}"></gravatar>
            <span ng-if="tx.toName && !showAddress">{{tx.toName}}</span>
            <span ng-if="tx.toName && showAddress">{{tx.origToAddress}}</span>
          </div>
        </div>

        <a class="item item-icon-right" ng-hide="!wallet" ng-click="showWalletSelector()">
          <span class="label" translate>From</span>
          <div class="wallet" ng-if="wallet">
            <i class="icon big-icon-svg" ng-include="'views/includes/walletIcon.html'"></i>
            <div>{{wallet.name}}</div>
          </div>
          <div class="wallet" ng-if="!wallet">
            <i class="icon big-icon-svg">
              <img src="img/icon-wallet.svg" ng-style="{'background-color': 'grey'}" class="bg"/>
            </i>
            <div>...</div>
          </div>
          <i class="icon bp-arrow-right"></i>
        </a>

        <a class="item item-icon-right" ng-if="wallet" ng-click="showDescriptionPopup(tx)">
          <span class="label" translate>Add Memo</span>
          <span class="item-note m10l">
            {{tx.description}}
          </span>
          <i class="icon bp-arrow-right"></i>
        </a>
        <div class="box-notification warning" ng-if="noWalletMessage" ng-click="openSupport()">
          <i class="icon i-info ion-alert-circled"></i>
          {{noWalletMessage}}
          <i class="icon i-arrow ion-ios-arrow-thin-right"></i>
        </div>
      </div>
    </div>
  </ion-content>

  <click-to-accept
    ng-click="approve(tx, wallet, statusChangeHandler)"
    ng-if="(!isCordova || isWindowsPhoneApp) && wallet"
    click-send-status="sendStatus"
    is-disabled="!wallet">
    {{buttonText}}
  </click-to-accept>

  <slide-to-accept
    ng-if="isCordova && !isWindowsPhoneApp && wallet"
    slide-on-confirm="approve(tx, wallet, statusChangeHandler)"
    slide-send-status="sendStatus"
    is-disabled="!wallet">
    {{buttonText}}
  </slide-to-accept>

  <slide-to-accept-success
    slide-success-show="sendStatus === 'success'"
    slide-success-on-confirm="onSuccessConfirm()"
    slide-success-hide-on-confirm="true">
    <span ng-show="wallet.m == 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Payment Sent</span>
    <span ng-show="wallet.m > 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Proposal Created</span>
    <span ng-show="!wallet.canSign() && !wallet.isPrivKeyExternal()" translate>Transaction Created</span>
  </slide-to-accept-success>

  <wallet-selector
    wallet-selector-title="walletSelectorTitle"
    wallet-selector-wallets="wallets"
    wallet-selector-selected-wallet="wallet"
    wallet-selector-show="walletSelector"
    wallet-selector-on-select="onWalletSelect">
  </wallet-selector>
</ion-view>
